package com.ysu.zyw.fk.security;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * SessionListener only use to log session's lifecycle.
 * <p>
 * Created by ZeRur on 2016/1/17.
 *
 * @author yaowu.zhang
 */
public class SessionLogger implements SessionListener {

    private static final Logger logger = LoggerFactory.getLogger(SessionLogger.class);

    public void onStart(Session session) {
        logger.debug("'session " + session.getId() + "' start, expires in" + new Date(new Date().getTime() + session.getTimeout()));
    }

    public void onStop(Session session) {
        logger.debug("'session " + session.getId() + "' stop.");
    }

    public void onExpiration(Session session) {
        logger.debug("'session " + session.getId() + "' expires.");
    }

}
